What is kolorist?
Kolorist is an npm package that provides utilities for styling terminal strings with colors and other text attributes. It is designed to be lightweight and easy to use, making it a great choice for adding visual enhancements to command-line applications.
What are kolorist's main functionalities?
Basic Color Styling
Kolorist allows you to style text with basic colors. The example demonstrates how to use red, green, and blue colors to style terminal output.
const { red, green, blue } = require('kolorist');
console.log(red('This is red text'));
console.log(green('This is green text'));
console.log(blue('This is blue text'));
Background Colors
Kolorist also supports background colors. The example shows how to apply red, green, and blue background colors to text.
const { bgRed, bgGreen, bgBlue } = require('kolorist');
console.log(bgRed('This text has a red background'));
console.log(bgGreen('This text has a green background'));
console.log(bgBlue('This text has a blue background'));
Text Attributes
In addition to colors, Kolorist can apply text attributes like bold, underline, and italic. The example demonstrates how to use these attributes.
const { bold, underline, italic } = require('kolorist');
console.log(bold('This text is bold'));
console.log(underline('This text is underlined'));
console.log(italic('This text is italicized'));
Other packages similar to kolorist
chalk
Chalk is a popular npm package for styling terminal strings. It offers a wide range of colors and text attributes, similar to Kolorist. Chalk is known for its extensive documentation and community support.
colors
Colors is another npm package for adding color and style to terminal output. It provides a simple API for applying colors and text attributes. Compared to Kolorist, Colors has been around longer and has a larger user base.
cli-color
CLI-Color is a package that provides a comprehensive set of tools for styling terminal output. It supports nested styles and complex formatting. CLI-Color is more feature-rich compared to Kolorist, but it may be overkill for simpler use cases.
kolorist
Tiny library to put colors into stdin/stdout :tada:
Usage
npm install --save-dev kolorist
import { red, cyan } from 'kolorist';
console.log(red(`Error: something failed in ${cyan('my-file.js')}.`));
You can also disable or enable colors globally via the following environment variables:
-
disable:
NODE_DISABLE_COLORS
NO_COLOR
TERM=dumb
FORCE_COLOR=0
-
enable:
FORCE_COLOR=1
FORCE_COLOR=2
FORCE_COLOR=3
On top of that you can disable colors right from node:
import { options, red } from 'kolorist';
options.enabled = false;
console.log(red('foo'));
You can also strip colors from a string:
import { red, stripColors } from 'kolorist';
console.log(stripColors(red('foo')));
License
MIT
, see the license file.